package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResCourse;
import com.hmkj.entity.ErspResPicture;

public class ErspResCourseDao extends JActiveTable {
	public ErspResCourseDao() {
		this.setDBTableName("ersp_res_course");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("res_id", "res_id", ActiveField.ftString, 36));
		AddField(new JActiveField("res_prozone", "res_prozone", ActiveField.ftString, 11));
		AddField(new JActiveField("res_teacher", "res_teacher", ActiveField.ftString, 200));
		AddField(new JActiveField("res_recommandgroup", "res_recommandgroup", ActiveField.ftString, 200));
		AddField(new JActiveField("res_recommandlevel", "res_recommandlevel", ActiveField.ftString, 100));
		AddField(new JActiveField("res_viewtype", "res_viewtype", ActiveField.ftString, 100));
		AddField(new JActiveField("res_instrument", "res_instrument", ActiveField.ftString, 500));
		AddField(new JActiveField("res_hascoursedoc", "res_hascoursedoc", ActiveField.ftString, 4));
		AddField(new JActiveField("res_hasreadingres", "res_hasreadingres", ActiveField.ftString, 4));
		AddField(new JActiveField("res_length", "res_length", ActiveField.ftString, 11));
		
		
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
        setDbKeyFields("id");
	}

	public int add(ErspResCourse vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("res_prozone", vo.getRes_prozone());
		setFieldValue("res_teacher", vo.getRes_teacher());
		setFieldValue("res_recommandgroup", vo.getRes_recommandgroup());
		setFieldValue("res_recommandlevel", vo.getRes_recommandlevel());
		setFieldValue("res_viewtype", vo.getRes_viewtype());
		setFieldValue("res_instrument", vo.getRes_instrument());
		setFieldValue("res_hascoursedoc", vo.getRes_hascoursedoc());
		setFieldValue("res_hasreadingres", vo.getRes_hasreadingres());
		setFieldValue("res_length", vo.getRes_length());
		
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspResCourse vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("res_prozone", vo.getRes_prozone());
		setFieldValue("res_teacher", vo.getRes_teacher());
		setFieldValue("res_recommandgroup", vo.getRes_recommandgroup());
		setFieldValue("res_recommandlevel", vo.getRes_recommandlevel());
		setFieldValue("res_viewtype", vo.getRes_viewtype());
		setFieldValue("res_instrument", vo.getRes_instrument());
		setFieldValue("res_hascoursedoc", vo.getRes_hascoursedoc());
		setFieldValue("res_hasreadingres", vo.getRes_hasreadingres());
		setFieldValue("res_length", vo.getRes_length());
		
		return this.getSQL();
	}
}
